package xyz.ddlnt.serviceusr.controller;

import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import xyz.ddlnt.commonutil.result.Result;
import xyz.ddlnt.model.dto.PostCommentAreaDTO;
import xyz.ddlnt.model.dto.PostCommentDTO;
import xyz.ddlnt.model.vo.MyCommentVO;
import xyz.ddlnt.model.vo.PostCommentVO;
import xyz.ddlnt.model.vo.ReplyCommentVO;
import xyz.ddlnt.serviceusr.service.PostCommentService;

import java.util.List;

/**
 * @author ZZULI_SE 210910
 * @data 2025/5/25 14:17
 */
@Slf4j
@RequestMapping("/post_comment")
@RestController
public class PostCommentController {
    @Resource
    private PostCommentService postCommentService;

    /**
     * 保存帖子评论
     *
     * @param postCommentDTO
     * @return
     */
    @PostMapping("/save")
    public Result<Boolean> savePostComment(@RequestBody PostCommentDTO postCommentDTO) {
        return Result.success(postCommentService.savePostComment(postCommentDTO));
    }

    /**
     * 获取帖子评论
     *
     * @param postCommentAreaDTO
     * @return
     */
    @PostMapping("/getPostComment")
    public Result<List<PostCommentVO>> getPostComment(@RequestBody PostCommentAreaDTO postCommentAreaDTO) {
        return Result.success(postCommentService.getPostComment(postCommentAreaDTO));
    }

    /**
     * 获取用户评论
     *
     * @param id
     * @return
     */
    @GetMapping("/getMyComment")
    public Result<List<MyCommentVO>> getMyComment(@RequestParam Long id) {
        return Result.success(postCommentService.getMyComment(id));
    }

    /**
     * 获取用户回复
     *
     * @param id
     * @return
     */
    @GetMapping("/getReplyComment")
    public Result<List<ReplyCommentVO>> getReplyComment(@RequestParam Long id) {
        return Result.success(postCommentService.getReplyComment(id));
    }

}
